<template>
  <div>
    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'right'
      }"
    >
      <el-button @click="closeDialog">关 闭</el-button>
      <el-button @click="checkDialog">选 择</el-button>
    </div>

    <TopFilter :list="topFilterList" labelWidth="85" @filterChange="changeHandle" @onCollapse="collapseHandle"></TopFilter>

    <!-- :fetchapi="fetchApi" -->
    <FilterTable
      ref="table"
      columnsRef="zxCusModal"
      :columns="columns"
      :params="fetchParams"
      :datakey="'rows'"
      :isPagination="true"
      :onColumnsChange="columns => (this.columns = columns)"
      :isSelectColumn="true"
      :onSyncTableData="tableHandle"
      selectionType="single"
      :onRowSelectChange="selectChangeHandle"
    >
      <template slot="controls"></template>
    </FilterTable>
  </div>
</template>
<script>
// import { selectExtendedInformation } from '@/api/claimManagement/business/repair';
export default {
  name: 'lbSelectGZLB',
  props: {
    gzdmQJBL: {
      type: String,
      default: '1'
    },
    rowData: {
      type: Object,
      default: () => ({})
    },
    ifConsign: {
      type: String,
      default: '1' // alert("ifConsign:"+ifConsign);
    }
  },
  data() {
    this.multipleTable3 = null;
    return {
      topFilterList: this.createTopFilters(),
      // fetchApi: selectExtendedInformation,
      columns: this.createTableColumns(),
      fetchParams: {
        // 初始化查询参数
        gzdmQJBL: this.gzdmQJBL
      },
      tableData: [] // 表单数据
    };
  },
  created() {
    // 页面加载走的方法
    // alert('this.gzdmQJBL:' + this.gzdmQJBL);
  },
  mounted() {
    this.BaseTable = this.$refs.table.$refs.pageTable;
  },
  methods: {
    createTopFilters() {
      return [
        {
          type: 'INPUT',
          label: '产品代码',
          fieldName: 'cpdmCode',
          placeholder: '请输入...'
        },
        {
          type: 'INPUT',
          label: '产品名称',
          fieldName: 'cpdmName',
          placeholder: '请输入...'
        }
      ];
    },
    createTableColumns() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 70,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '产品代码',
          dataIndex: 'cpdmCode',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '产品名称',
          dataIndex: 'cpdmName',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          type: 'SELECT',
          title: '产品周期',
          dataIndex: 'bpzq',
          sorter: true,
          filter: true,
          itemList: [
            { text: '上传状态1', value: 1001 },
            { text: '上传状态2', value: 1002 }
          ]
          //           filterType: 'checkbox',
          //           filterItems:this.createDictList('9140'),
          //           render: props => {
          //             return <span>{this.createDictText(props.row.saleFormat,'9140')}</span>;
          //           }
        },
        {
          type: 'SELECT',
          title: '产品类型',
          dataIndex: 'cpdmType',
          sorter: true,
          filter: true,
          itemList: [
            { text: '上传状态1', value: 1001 },
            { text: '上传状态2', value: 1002 }
          ]
          //           filterType: 'checkbox',
          //           filterItems:this.createDictList('9140'),
          //           render: props => {
          //             return <span>{this.createDictText(props.row.saleFormat,'9140')}</span>;
          //           }
        },
        {
          type: 'SELECT',
          title: '核销方式',
          dataIndex: 'hxfs',
          sorter: true,
          filter: true,
          itemList: [
            { text: '上传状态1', value: 1001 },
            { text: '上传状态2', value: 1002 }
          ]
          //           filterType: 'checkbox',
          //           filterItems:this.createDictList('9140'),
          //           render: props => {
          //             return <span>{this.createDictText(props.row.saleFormat,'9140')}</span>;
          //           }
        },
        {
          type: 'SELECT',
          title: '销售期限',
          dataIndex: 'xsqx',
          sorter: true,
          filter: true,
          itemList: [
            { text: '上传状态1', value: 1001 },
            { text: '上传状态2', value: 1002 }
          ]
          //           filterType: 'checkbox',
          //           filterItems:this.createDictList('9140'),
          //           render: props => {
          //             return <span>{this.createDictText(props.row.saleFormat,'9140')}</span>;
          //           }
        },
        {
          title: '里程上限(公里)',
          dataIndex: 'lcsx',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '价格',
          dataIndex: 'jg',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '车辆用途',
          dataIndex: 'clyt',
          sorter: true,
          filter: true,
          filterType: 'input'
        }
        // {
        //   title: '销售价格',
        //   dataIndex: 'xsjg',
        //   sorter: true,
        //   filter: true,
        //   filterType: 'input'
        // },
      ];
    },

    // 行选中状态变化时的回调
    selectChangeHandle(val) {
      this.multipleTable3 = val; //  this.multipleTable 选中的值
      console.log(val);
    },

    checkDialog() {
      alert('1');
      this.$emit('setCustomer2', this.multipleTable3);
    },
    // 搜索
    changeHandle(val) {
      this.fetchParams = Object.assign({}, val);
    },
    collapseHandle() {
      this.$nextTick(() => {
        this.BaseTable.EXECUTE_RESET_HEIGHT();
      });
    },
    closeDialog(param) {
      this.$emit('closeCPDM', false, param);
    },
    // table动态回调函数
    tableHandle(val) {
      this.tableData = val;
    }
  }
};
</script>

<style lang="less" scoped></style>
